<?php

namespace App\Http\Controllers;

use App\Http\Controllers\common\BaseController;
use App\Models\HousePurchase;
use App\Models\RentHouseModel;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;

use Illuminate\Support\Facades\DB;
class RentHouseController extends BaseController
{
    /**
     * 房屋求租系统
     */
    public function rentHouse()
    {
        //接受参数
        $info=\request()->post();
        $rent_hao="ahao";
        $data=DB::table('rent_house')->insert($info);;
        Cache::put($rent_hao,$data,500);
        try {
            if($data){
                return $this->retJson('200','添加成功',$data);
            }else{
                return $this->retJson('400','添加失败','');
            }
        }catch (\Exception $e){
            echo "异常捕获".$e;
        }

    }

    /**
     * 查询房屋求购
     */
    public function housePurchase()
    {
        $data=HousePurchase::all();
        try {
            if($data){
                return $this->retJson('200','查询成功',$data);
            }else{
                return $this->retJson('400','查询失败','');
            }
        }catch (\Exception $exception){
            echo "异常捕获".$exception;
        }
    }

    /**
     * 查询房屋求购详情列表
     */
    public function housePurchaseFind()
    {
        $id=request()->all();
        $data=HousePurchase::find($id);
         try {
            if($data){
                return $this->retJson('200','查询成功',$data);
            }else{
                return $this->retJson('400','查询失败','');
            }
        }catch (\Exception $exception){
            echo "异常捕获".$exception;
        }

    }
}
